package org.balthie.cal.impl.cmd.spec;

import java.util.Deque;

import org.balthie.cal.common.ex.CalculatorException;
import org.balthie.cal.common.spec.AbstractSpecification;
import org.balthie.cal.core.ICommand;

/**
 * @author：balthie@126.com
 * @createtime ： 2023年3月7日 下午1:37:55
 * @description 指令集暂存区的规格 父类
 * @since version 初始于版本 0.0.1-SNAPSHOT
 */
public abstract class AbsCmdsSpec extends AbstractSpecification<Deque<ICommand>> {

	@Override
	public boolean isSatisfiedBy(Deque<ICommand> candidate) {
		return doCheck(candidate, Boolean.FALSE);
	}

	@Override
	public void check(Deque<ICommand> candidate) throws CalculatorException  {
		doCheck(candidate, Boolean.TRUE);
	}

	protected abstract boolean doCheck(Deque<ICommand> candidate, boolean isThrow);
}
